<?php
namespace BP\GPM;
require_once("BP/En/Map.php");
require_once("BP/Web/WebUser.php");
require_once("java/util/regex/Matcher.php");
require_once("java/util/regex/Pattern.php");
class Bar extends EntityNoName {
	public function getHisUAC () 
	{
		$uac = new UAC();
		$uac->IsInsert =  FALSE ;
		return $uac;
	}
	public function getMoreUrl () 
	{
		return $this->GetValStrByKey(BarAttr::$MoreUrl);
	}
	public function setMoreUrl ($value) // [String value]
	{
		$this->SetValByKey(BarAttr::$MoreUrl, $value);
	}
	public function getMoreLab () 
	{
		return $this->GetValStrByKey(BarAttr::$MoreLab);
	}
	public function setMoreLab ($value) // [String value]
	{
		$this->SetValByKey(BarAttr::$MoreLab, $value);
	}
	public function getTitle () 
	{
		return $this->GetValStrByKey(BarAttr::$Title);
	}
	public function setTitle ($value) // [String value]
	{
		$this->SetValByKey(BarAttr::$Title, $value);
	}
	public function getIsDel () 
	{
		return $this->GetValBooleanByKey(BarAttr::$IsDel);
	}
	public function setIsDel ($value) // [boolean value]
	{
		$this->SetValByKey(BarAttr::$IsDel, $value);
	}
	public function getBarType () 
	{
		return $this->GetValIntByKey(BarAttr::$BarType);
	}
	public function setBarType ($value) // [int value]
	{
		$this->SetValByKey(BarAttr::$BarType, $value);
	}
	public function getOpenWay () 
	{
		return $this->GetValIntByKey(BarAttr::$OpenWay);
	}
	public function setOpenWay ($value) // [int value]
	{
		$this->SetValByKey(BarAttr::$OpenWay, $value);
	}
	public function getIdx () 
	{
		return $this->GetValIntByKey(BarAttr::$Idx);
	}
	public function setIdx ($value) // [int value]
	{
		$this->SetValByKey(BarAttr::$Idx, $value);
	}
	public function getTag1 () 
	{
		return $this->GetValStrByKey(BarAttr::$Tag1);
	}
	public function setTag1 ($value) // [String value]
	{
		$this->SetValByKey(BarAttr::$Tag1, $value);
	}
	public function getTag2 () 
	{
		return $this->GetValStrByKey(BarAttr::$Tag2);
	}
	public function setTag2 ($value) // [String value]
	{
		$this->SetValByKey(BarAttr::$Tag2, $value);
	}
	public function getTag3 () 
	{
		return $this->GetValStrByKey(BarAttr::$Tag3);
	}
	public function setTag3 ($value) // [String value]
	{
		$this->SetValByKey(BarAttr::$Tag3, $value);
	}
	public function getDocGenerRDT () 
	{
		return $this->GetValStrByKey(BarAttr::$DocGenerRDT);
	}
	public function setDocGenerRDT ($value) // [String value]
	{
		$this->SetValByKey(BarAttr::$DocGenerRDT, $value);
	}
	public function getWidth () 
	{
		return $this->GetValStrByKey(BarAttr::$Width);
	}
	public function setWidth ($value) // [String value]
	{
		$this->SetValByKey(BarAttr::$Width, $value);
	}
	public function getHeight () 
	{
		return $this->GetValStrByKey(BarAttr::$Height);
	}
	public function setHeight ($value) // [String value]
	{
		$this->SetValByKey(BarAttr::$Height, $value);
	}
	public function getDoc () 
	{
		$html = "";
		switch ($this->getBarType()) {
			case 0:
				$html += "\t\n<ul style='padding-left:13px;width:200px;overflow:hidden;'>";
				$sql = $this->getTag1();
				$sql = $sql->replace("~", "'");
				$sql = $sql->replace("@WebUser.getNo()", $WebUser->getNo());
				$sql = $sql->replace("@WebUser.getName()", $WebUser->getName());
				$dt = DBAccess->RunSQLReturnTable($sql);
				foreach ($dt->Rows as $dr) 				{
					$no = $dr->get("No");
					$name = $dr->get("Name");
					$url = $this->getTag2();
					$url = $url->replace("~", "'");
					$url = $this->GetParameteredString($url, $dr);
					if ($url->toLowerCase()->startsWith("javascript:"))
					{
						$html += (((("\t\n<li><a href=\"" . $url) . "\">") . $name) . "</a></li>");
					}
					else
					{
						switch ($this->getOpenWay()) {
							case 0:
								$html += (((("\t\n<li><a href=\"" . $url) . "\"  target='_blank' >") . $name) . "</a></li>");
								break;
							case 1:
								$html += (((("\t\n<li><a href=\"" . $url) . "\" target='_self' >") . $name) . "</a></li>");
								break;
							case 2:
								$html += (((((("\t\n<li><a href=\"" . $url) . "\" target=' ") . $this->getNo()) . " ' >") . $name) . "</a></li>");
								break;
							default:
								break;
						}
					}
				}
				$html += "\t\n</ul>";
				return $html;
			case 1:
				return $this->getTag1();
			default:
				break;
		}
		return $this->GetValStrByKey(BarAttr::$Doc);
	}
	protected function GetParameteredString ($stringInput, $dr) // [String stringInput, DataRow dr]
	{
		$regE = "@[a-zA-Z]([\\w-]*[a-zA-Z0-9])?";
		$pattern = $Pattern->compile($regE);
		$matcher = $pattern->matcher($stringInput);
		while ($matcher->find()) 
		{
			$v = $matcher->group();
			$f = $matcher->group()->substring(1);
			$stringInput = $stringInput->replace($v, $String->format("%1$s", $dr->getValue($f)));
		}
		return $stringInput;
	}
	public static function constructor__ () 
	{
		$me = new self();
		return $me;
	}
	public static function constructor__String ($no) // [String no]
	{
		$me = new self();
		$me->setNo($no);
		$me->Retrieve();
		return $me;
	}
	public function getEnMap () 
	{
		if (($this->get_enMap() != NULL))
		{
			return $this->get_enMap();
		}
		$map = new Map("GPM_Bar");
		$map->setDepositaryOfEntity($Depositary->None);
		$map->setDepositaryOfMap($Depositary->Application);
		$map->setEnDesc("信息�?");
		$map->setEnType($EnType->Sys);
		$map->AddTBStringPK(BarAttr::$No, NULL, "编号",  TRUE ,  FALSE , 1, 200, 200);
		$map->AddTBString(BarAttr::$Name, NULL, "名称",  TRUE ,  FALSE , 0, 3900, 20);
		$map->AddTBString(BarAttr::$Title, NULL, "标题",  TRUE ,  FALSE , 0, 3900, 20);
		$map->AddDDLSysEnum(BarAttr::$OpenWay, 0, "打开方式",  TRUE ,  TRUE , BarAttr::$OpenWay, "@0=新窗口@1=本窗口@2=覆盖新窗�?");
		$map->AddBoolean(BarAttr::$IsLine,  FALSE , "是否独占�?�?",  TRUE ,  TRUE );
		$map->AddTBString(BarAttr::$MoreUrl, NULL, "更多标签Url",  TRUE ,  FALSE , 0, 3900, 20,  TRUE );
		$map->AddSearchAttr(BarAttr::$OpenWay);
		$this->set_enMap($map);
		return $this->get_enMap();
	}
	public function GetDocument () 
	{
		$barBase = $ClassFactory->GetObject_OK($this->getNo());
		if (($barBase == NULL))
		{
			$this->Delete();
			return "err@已经删除.";
		}
		return $barBase->getDocuments();
	}
	protected function afterDelete () 
	{
		$sql = (("DELETE FROM GPM_BarEmp WHERE FK_Bar=' " . $this->getNo()) . " '");
		DBAccess::RunSQL($sql);
		parent->afterDelete();
	}
}
?>
